package laba1.task2;

import java.util.List;

/**
 *
 * @author yakimovich
 */
public class Triangle extends Figure {

    private Point p1;
    private Point p2;
    private Point p3;
    private List<Point> points = getList();

    /**
     * creates a Triangle by default
     */
    public Triangle() {
    }

    /**
     *created a Triangle by the specified points
     */
    public Triangle(Point p1, Point p2, Point p3) {
        this.p1 = p1;
        this.p2 = p2;
        this.p3 = p3;

        points.add(p1);
        points.add(p2);
        points.add(p3);
    }

    /**
     *displays the coordinates of the Triangle on the screen
     */
    @Override
    public void draw() {
        if (getP1() != null && getP2() != null && getP3() != null) {
            System.out.println("Triangle{" + getP1().toString() + getP2().toString() + getP3().toString() + '}');
        } else {
            System.out.println("Triangle. Coordinates are not set");
        }
    }

    /**
     * scales the Triangle by a factor
     *
     * @param factor scaling factor
     */
    @Override
    public void scale(int factor) {
        for (Point p : getPoints()) {
            if (p != null) {
                p.translate(factor);
            }
        }
    }

    /**
     * @return the p1
     */
    public Point getP1() {
        return p1;
    }

    /**
     * @param p1 the p1 to set
     */
    public void setP1(Point p1) {
        this.p1 = p1;
    }

    /**
     * @return the p2
     */
    public Point getP2() {
        return p2;
    }

    /**
     * @param p2 the p2 to set
     */
    public void setP2(Point p2) {
        this.p2 = p2;
    }

    /**
     * @return the p3
     */
    public Point getP3() {
        return p3;
    }

    /**
     * @param p3 the p3 to set
     */
    public void setP3(Point p3) {
        this.p3 = p3;
    }

    /**
     * @return the points
     */
    public List<Point> getPoints() {
        return points;
    }

    /**
     * @param points the points to set
     */
    public void setPoints(List<Point> points) {
        this.points = points;
    }
}
